/****************************************************************************
 * @file mem_trace.h
 * @brief header file of mem_trace
 * @version <0.0.1>
 * @date 2022-04-06
 *
 * @copyright Copyright(C) 2021-2022 Tuya Inc. All Rights Reserved.
 ****************************************************************************/

#ifndef __MEM_TRACE_H__
#define __MEM_TRACE_H__


/****************************************************************************
 * Included Files
 ****************************************************************************/
#include "log.h"

/****************************************************************************
 * Pre-processor Definitions
 ****************************************************************************/

#define _LOG(...)    do{ log_printf(__VA_ARGS__); }while(0)

/****************************************************************************
 * Public Type Declarations
 ****************************************************************************/

/****************************************************************************
 * Public Data
 ****************************************************************************/

/****************************************************************************
 * Public Function Prototypes
 ****************************************************************************/

#define traceFREE(pv, size) \
    do { \
        _LOG("f %x %x %d\r\n",  __builtin_return_address(0), pv, size); \
    } while(0)


#define traceMALLOC(pv, size) \
    do { \
        size_t tmp = pxBlock->xBlockSize; \
        tmp &= ~xBlockAllocatedBit; \
        _LOG("m %x %x %d\r\n", __builtin_return_address(0), pv, tmp); \
    } while(0)

#endif /* !__MEM_TRACE_H__ */


